#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000, maxm=100000, maxlogn=17, maxz=1000000000;

int max(int a, int b) {
  return a>b ? a : b;
}

class SegmentTree {
public:
  int l, r, v;
  SegmentTree *left, *right;

  SegmentTree();
  SegmentTree(int l, int r);

  void add(int t, int tv);
  int getMax();
  void merge(SegmentTree *t);
};

SegmentTree::SegmentTree() {
  v=0;
}

SegmentTree nil;

SegmentTree* newSegmentTree(int l, int r) {
  static int size;
  static SegmentTree sgtpool[10000000];
  size++;
  sgtpool[size].l=l, sgtpool[size].r=r;
  sgtpool[size].v=0, sgtpool[size].left=sgtpool[size].right=&nil;
  return sgtpool+size;
}

void SegmentTree::add(int t, int tv) {
  if (l==r) {
    v += tv;
  } else {
    int mid=(l+r)/2;
    if (t<=mid) {
      if (left==&nil) {
	left = newSegmentTree(1, mid);
      }
      left->add(t, tv);
    } else {
      if (right==&nil) {
	right = newSegmentTree(mid+1, r);
      }
      right->add(t, tv);
    }
    v = max(left->v, right->v);
  }
}

int SegmentTree::getMax() {
  if (v==0) {
    return 0;
  } else if (l==r) {
    return l;
  } else {
    return left->v>=right->v ? left->getMax() : right->getMax();
  }
}

void SegmentTree::merge(SegmentTree *o) {
  if (l==r) {
    v += o->v;
  } else {
    if (o->left!=&nil) {
      if (left==&nil) {
	left = o->left;
      } else {
	left->merge(o->left);
      }
    }
    if (o->right!=&nil) {
      if (right==&nil) {
	right = o->right;
      } else {
	right->merge(o->right);
      }
    }
    v = max(left->v, right->v);
  }
  // delete o;
}

class Graph {
public:
  SegmentTree *sgt[maxn+1];
  int n, m, size, ind[maxn+1], to[2*maxn-1], link[2*maxn-1], add[maxn+1], rice[maxm*4+1], dec[maxn+1], f[maxn+1][maxlogn+1], dep[maxn+1], linkr[maxm*4+1], ans[maxn+1];

  void addSide(int u, int v) {
    m++;
    to[m] = v;
    link[m] = ind[u];
    ind[u] = m;
  }

  void build(int o, int fa) {
    f[o][0] = fa;
    dep[o] = dep[fa]+1;
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=fa) {
	build(to[i], o);
      }
    }
  }

  void initF() {
    build(1, 0);

    for (int i=1; i<=maxlogn; i++) {
      for (int j=1; j<=n; j++) {
	f[j][i] = f[f[j][i-1]][i-1];
      }
    }
  }

  int lca(int u, int v) {
    if (dep[u]<dep[v]) {
      int temp;
      temp = u, u = v, v = temp;
    }
    for (int i=maxlogn; i>=0; i--) {
      if (dep[f[u][i]]>=dep[v]) {
	u = f[u][i];
      }
    }
    if (u==v) {
      return u;
    }
    for (int i=maxlogn; i>=0; i--) {
      if (f[u][i]!=f[v][i]) {
	u = f[u][i], v = f[v][i];
      }
    }
    return f[u][0];
  }

  void addRice(int u, int v, int z) {
    size++;
    rice[size] = z;
    linkr[size] = add[u];
    add[u] = size;
    size++;
    rice[size] = z;
    linkr[size] = dec[v];
    dec[v] = size;
  }

  void solve(int o) {
    sgt[o] = newSegmentTree(1, maxz);
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=f[o][0]) {
	solve(to[i]);
	sgt[o]->merge(sgt[to[i]]);
      }
    }
    for (int i=add[o]; i; i=linkr[i]) {
      sgt[o]->add(rice[i], 1);
    }
    for (int i=dec[o]; i; i=linkr[i]) {
      sgt[o]->add(rice[i], -1);
    }
    ans[o] = sgt[o]->getMax();
  }
};

int read() {
  char c;
  for (c=getchar(); c<'0' || c>'9'; c=getchar());
  int ret=0;
  for (; c>='0' && c<='9'; c=getchar()) {
    ret = ret*10+c-'0';
  }
  return ret;
}

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif
  static Graph g;
  int n, m;
  scanf("%d %d", &n, &m);
  g.n = n;
  for (int i=1; i<n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g.addSide(u, v);
    g.addSide(v, u);
  }
  g.initF();
  for (int i=1; i<=m; i++) {
    int x, y, z, lca;
    scanf("%d %d %d", &x, &y, &z);
    lca = g.lca(x, y);
    if (lca==x) {
      g.addRice(y, g.f[x][0], z);
    } else if (lca==y) {
      g.addRice(x, g.f[y][0], z);
    } else {
      g.addRice(x, g.f[lca][0], z);
      g.addRice(y, lca, z);
    }
  }

  g.solve(1);

  for (int i=1; i<=n; i++) {
    printf("%d\n", g.ans[i]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
